package com.iwhalecloud.bss.kite.cucc.service.attr.handler;

import com.iwhalecloud.bss.kite.common.constant.KeyConsts;
import com.iwhalecloud.bss.kite.common.util.KiteStringUtils;
import com.iwhalecloud.bss.kite.cucc.service.util.ProdCateUtil;
import com.iwhalecloud.bss.kite.manager.api.IOperateSceneInstService;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttr;
import com.iwhalecloud.bss.kite.manager.inst.KiteInst;
import com.iwhalecloud.bss.kite.service.attr.data.CustAttrData;
import com.iwhalecloud.bss.kite.service.attr.handler.AbstractAttrHandler;
import org.springframework.beans.factory.annotation.Autowired;
/**
 * @author liaojing
 * @create 2021-12-120-09:41
 */
public class GreenhousMonitoringOrderQuantityAttrHandler extends AbstractAttrHandler<KiteInst, CustAttrData> {
    @Autowired
    private IOperateSceneInstService operateSceneInstService;

    @Override
    public void after(KiteAttr attr, KiteInst inst, CustAttrData data) {
        super.after(attr, inst, data);
        //产品变更 延期分组置灰
        if (KiteStringUtils.equalsAny(data.getServiceOfferId(), "2826","2024")
                && (KiteStringUtils.isEqual(attr.getGroupId(), "300000173") || KiteStringUtils.equalsAny(inst.getSpecId(), ProdCateUtil.getMainMemberProdId(ProdCateUtil.GIFT_YFDPJK_PROD)))) {
            attr.setIsEdit(KeyConsts.IFTRUE_F);
            operateSceneInstService
                    .setAttr(data.getSceneInstId(), inst.getInstType(), inst.getInstId(), attr);
        }
        //融和追加和产品变更  销售价和订购数量都置灰
        if (KiteStringUtils.equalsAny(data.getServiceOfferId(), "2826","2024")
                &&  (KiteStringUtils.isEqual(attr.getGroupId(), "300002017") || KiteStringUtils.equalsAny(inst.getSpecId(), ProdCateUtil.getMainMemberProdId(ProdCateUtil.GIFT_YFDPJK_PROD)))) {
            inst.getAttrMap().get("200001696").setIsEdit(KeyConsts.IFTRUE_F);
            inst.getAttrMap().get("200004107").setIsEdit(KeyConsts.IFTRUE_F);
            operateSceneInstService
                    .setAttr(data.getSceneInstId(), inst.getInstType(), inst.getInstId(), attr);
        }

    }

}
